<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/blog/css/main.css">


<link rel="stylesheet" href="/blog/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/blog/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"always","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta property="og:type" content="website">
<meta property="og:title" content="ingrun">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="ingrun">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="ingrun">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>ingrun</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/blog/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">ingrun</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">不吃花生</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/blog/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/blog/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/08/01/uniapp%20swiper%20%E9%80%89%E9%A1%B9%E5%8D%A1%E5%AE%9E%E7%8E%B0%E9%AB%98%E5%BA%A6%E8%87%AA%E9%80%82%E5%BA%94/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2022/08/01/uniapp%20swiper%20%E9%80%89%E9%A1%B9%E5%8D%A1%E5%AE%9E%E7%8E%B0%E9%AB%98%E5%BA%A6%E8%87%AA%E9%80%82%E5%BA%94/" class="post-title-link" itemprop="url">uniapp swiper 选项卡实现高度自适应</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2022-08-01 00:00:00 / 修改时间：18:15:16" itemprop="dateCreated datePublished" datetime="2022-08-01T00:00:00+08:00">2022-08-01</time>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <blockquote>
<p><a target="_blank" rel="noopener" href="https://uviewui.com/components/image.html">https://uviewui.com/components/image.html</a></p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">    &lt;view class&#x3D;&quot;body-div&quot;&gt;</span><br><span class="line">      &lt;view class&#x3D;&quot;_tabs_p&quot;&gt;</span><br><span class="line">        &lt;u-tabs :list&#x3D;&quot;tabsList&quot; :is-scroll&#x3D;&quot;false&quot; :current&#x3D;&quot;tabsCurrent&quot; @change&#x3D;&quot;change&quot; font-size&#x3D;&quot;32&quot; height&#x3D;&quot;100&quot;&gt;</span><br><span class="line">        &lt;&#x2F;u-tabs&gt;</span><br><span class="line">      &lt;&#x2F;view&gt;</span><br><span class="line">      &lt;swiper class&#x3D;&quot;swiper&quot; :current&#x3D;&quot;tabsCurrent&quot; @change&#x3D;&quot;swiperChange&quot; :style&#x3D;&quot;&#123;&#39;height&#39;: swiperHeight+&#39;px&#39;&#125;&quot;&gt;</span><br><span class="line">        &lt;swiper-item&gt;</span><br><span class="line">          &lt;view class&#x3D;&quot;list__ list0&quot; &gt; &lt;&#x2F;view&gt;</span><br><span class="line">        &lt;&#x2F;swiper-item&gt;</span><br><span class="line">        &lt;swiper-item&gt;</span><br><span class="line">          &lt;view class&#x3D;&quot;list__ list1&quot; &gt; &lt;&#x2F;view&gt;</span><br><span class="line">        &lt;&#x2F;swiper-item&gt;</span><br><span class="line">      &lt;&#x2F;swiper&gt;</span><br><span class="line">    &lt;&#x2F;view&gt;</span><br><span class="line">&lt;&#x2F;template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script&gt;</span><br><span class="line"></span><br><span class="line">  export default &#123;</span><br><span class="line"></span><br><span class="line">    data() &#123;</span><br><span class="line">      return &#123;</span><br><span class="line">        swiperHeight: 0,</span><br><span class="line">        tabsCurrent: 0,</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;,</span><br><span class="line"></span><br><span class="line">    mounted() &#123;</span><br><span class="line">      this.initSwiperHeight(&#39;.list0&#39;)</span><br><span class="line">    &#125;,</span><br><span class="line">    methods: &#123;</span><br><span class="line">      initSwiperHeight(list) &#123;</span><br><span class="line">        const query &#x3D; uni.createSelectorQuery().in(this);</span><br><span class="line">        query.select(list).boundingClientRect(data &#x3D;&gt; &#123;</span><br><span class="line">          this.swiperHeight &#x3D; data.height + 20</span><br><span class="line">        &#125;).exec();</span><br><span class="line">      &#125;,</span><br><span class="line">      change(index) &#123;</span><br><span class="line">        this.tabsCurrent &#x3D; index;</span><br><span class="line">        this.initSwiperHeight(&#39;.list&#39; + index)</span><br><span class="line">      &#125;,</span><br><span class="line">      swiperChange(e) &#123;</span><br><span class="line">        const index &#x3D; e.detail.current;</span><br><span class="line">        this.tabsCurrent &#x3D; index;</span><br><span class="line">        this.initSwiperHeight(&#39;.list&#39; + index)</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;</span><br><span class="line">&lt;&#x2F;script&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/05/05/JS%20%E7%9A%84%E4%B8%80%E4%BA%9B%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2022/05/05/JS%20%E7%9A%84%E4%B8%80%E4%BA%9B%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/" class="post-title-link" itemprop="url">JS 的一些常用操作</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-05-05 00:00:00" itemprop="dateCreated datePublished" datetime="2022-05-05T00:00:00+08:00">2022-05-05</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-05-07 11:38:41" itemprop="dateModified" datetime="2022-05-07T11:38:41+08:00">2022-05-07</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h3 id="查询符合条件的第一个元素"><a href="#查询符合条件的第一个元素" class="headerlink" title="查询符合条件的第一个元素"></a>查询符合条件的第一个元素</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> s = [<span class="number">1</span>,<span class="number">23</span>,<span class="number">4</span>]</span><br><span class="line"></span><br><span class="line">s.find(<span class="function"><span class="params">i</span> =&gt;</span> i === <span class="number">1</span>)</span><br><span class="line"><span class="comment">// 1</span></span><br><span class="line">s.find(<span class="function"><span class="params">i</span> =&gt;</span> i === <span class="number">2</span>)</span><br><span class="line"><span class="comment">// undefined   无符合条件</span></span><br><span class="line">s.findIndex(<span class="function"><span class="params">i</span> =&gt;</span> i === <span class="number">2</span>)</span><br><span class="line"><span class="comment">// -1   无符合条件</span></span><br><span class="line">s.some(<span class="function"><span class="params">i</span> =&gt;</span> i === <span class="number">1</span>)</span><br><span class="line"><span class="comment">// true</span></span><br><span class="line">s.some(<span class="function"><span class="params">i</span> =&gt;</span> i === <span class="number">2</span>)</span><br><span class="line"><span class="comment">// false  无符合条件</span></span><br><span class="line">s.findIndex(<span class="function"><span class="params">i</span> =&gt;</span> i === <span class="number">23</span>)</span><br><span class="line"><span class="comment">// 1   返回下标</span></span><br></pre></td></tr></table></figure>


<h3 id="map"><a href="#map" class="headerlink" title="map"></a>map</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 遍历数组，  并将返回值组合成新数组返回</span></span><br><span class="line"><span class="keyword">let</span> s = [<span class="number">1</span>,<span class="number">23</span>,<span class="number">4</span>]</span><br><span class="line"></span><br><span class="line">s.map(<span class="function"><span class="params">e</span> =&gt;</span> &#123;<span class="built_in">console</span>.log(e); <span class="keyword">return</span> e+<span class="number">10</span>&#125; )</span><br><span class="line"><span class="number">1</span></span><br><span class="line"><span class="number">23</span></span><br><span class="line"><span class="number">4</span></span><br><span class="line">(<span class="number">3</span>) [<span class="number">11</span>, <span class="number">33</span>, <span class="number">14</span>]</span><br><span class="line"></span><br></pre></td></tr></table></figure>


<h3 id="filter"><a href="#filter" class="headerlink" title="filter"></a>filter</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 返回符合条件的所有数据 并组成新数组</span></span><br><span class="line"><span class="keyword">let</span> s = [<span class="number">1</span>,<span class="number">23</span>,<span class="number">4</span>]</span><br><span class="line"></span><br><span class="line">s.filter( <span class="function"><span class="params">i</span> =&gt;</span> i &gt; <span class="number">1</span>)</span><br><span class="line">(<span class="number">2</span>) [<span class="number">23</span>, <span class="number">4</span>]</span><br></pre></td></tr></table></figure>



      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/09/29/nohup/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2021/09/29/nohup/" class="post-title-link" itemprop="url">LINUX 将进程放入后台执行，SSH 断开导致进程结束</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-09-29 11:40:46" itemprop="dateCreated datePublished" datetime="2021-09-29T11:40:46+08:00">2021-09-29</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-10-19 10:00:20" itemprop="dateModified" datetime="2021-10-19T10:00:20+08:00">2021-10-19</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="（NOHUP-SETSID-amp-DISOWN）"><a href="#（NOHUP-SETSID-amp-DISOWN）" class="headerlink" title="（NOHUP, SETSID, &amp;, DISOWN）"></a>（NOHUP, SETSID, &amp;, DISOWN）</h2><p>Linux 将进程放入后台执行，解决网络，ssh断开导致进程结束（nohup,  setsid,  &amp;, disown）</p>
<p>1、nohup 命令</p>
<p>我们知道，当用户注销（logout）或者网络断开时，终端会收到 HUP（hangup）信号从而关闭其所有子进程。因此，我们的解决办法就有两种途径：要么让进程忽略 HUP 信号，要么让进程运行在新的会话里从而成为不属于此终端的子进程</p>
<p>nohup &amp; 命令并不能从根本上解决ssh断开问题。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">1 [root@Searchsvc1 go-mysql-elasticsearch]# nohup tail -f nohup.out &amp;</span><br><span class="line">2 [1] 21509</span><br></pre></td></tr></table></figure>
<p>pid所属的父id为：21476</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1 [root@Searchsvc1 go-mysql-elasticsearch]# ps -ef |grep tail</span><br><span class="line">2 root     21509 21476 98 21:39 pts&#x2F;1    00:01:17 tail -f nohup.out</span><br><span class="line">3 root     21518 20971  0 21:40 pts&#x2F;0    00:00:00 grep tail</span><br></pre></td></tr></table></figure>
<p>通过 pstree  -p 查看线程树可知它属于ssh的一个子线程，所以关闭ssh的时候，会将其子线程hangup。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">1   ├─sshd(1472)─┬─sshd(20967)───bash(20971)───pstree(21516)</span><br><span class="line">2         │            └─sshd(21472)───bash(21476)───tail(21509)</span><br></pre></td></tr></table></figure>


<p>2、 setsid 命令</p>
<p>我们换个角度思考，如果我们的进程不属于接受 HUP 信号的终端的子进程，那么自然也就不会受到 HUP 信号的影响了。setsid 就能帮助我们做到这一点。让我们先来看一下 setsid 的帮助信息。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">1 [root@Searchsvc1 go-mysql-elasticsearch]# setsid tail -f nohup.out </span><br><span class="line">2 [root@Searchsvc1 go-mysql-elasticsearch]# 2017&#x2F;11&#x2F;16 21:34:30 master.go:54: [info] save position (mysql-bin.000052, 98963482)</span><br><span class="line">3 2017&#x2F;11&#x2F;16 21:35:13 master.go:54: [info] save position (mysql-bin.000052, 98966359)</span><br><span class="line">setsid 命令会将结果信息输出到控制台，并没有从真正意义上将线程转向后台执行</span><br><span class="line">我们再来看下执行该命令后的进程的父pid:1 ,已经跟ssh已经没有关系了。</span><br></pre></td></tr></table></figure>


<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">1 init(1)─┬─abrtd(1572)</span><br><span class="line">2         ├─acpid(1363)</span><br><span class="line">3         ├─atd(1609)</span><br><span class="line">4     </span><br><span class="line">5         ├─sshd(1472)─┬─sshd(20967)───bash(20971)───pstree(21650)</span><br><span class="line">6         │            └─sshd(21472)───bash(21476)</span><br><span class="line">7         ├─tail(21645)</span><br></pre></td></tr></table></figure>


<p>这里还有一个关于 subshell 的小技巧。我们知道，将一个或多个命名包含在“()”中就能让这些命令在子 shell 中运行中，从而扩展出很多有趣的功能，我们现在要讨论的就是其中之一。当我们将”&amp;”也放入“()”内之后，我们就会发现所提交的作业并不在作业列表中，也就是说，是无法通过<code>jobs</code>来查看的。让我们来看看为什么这样就能躲过 HUP 信号的影响吧。</p>
<p>但用&amp;能将进程转向后台，但是</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">1 ├─sshd(1472)─┬─sshd(20967)───bash(20971)───pstree(21662)</span><br><span class="line">2         │            └─sshd(21472)───bash(21476)───tail(21655)</span><br></pre></td></tr></table></figure>
<p>（）命令</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">1 [root@Searchsvc1 go-mysql-elasticsearch]# (tail -f nohup.out)</span><br><span class="line">2 2017&#x2F;11&#x2F;16 21:57:38 master.go:54: [info] save position (mysql-bin.000052, 99185120)</span><br><span class="line">1  ├─sshd(1472)─┬─sshd(20967)───bash(20971)───pstree(21664)</span><br><span class="line">2         │            └─sshd(21472)───bash(21476)───tail(21663)</span><br></pre></td></tr></table></figure>
<p>从上面可以看出&amp;,()都会将结果信息输出到控制台，而且转向后台的线程会因为ssh的关闭而影响，但是执行（tail -f nohup.out &amp;）却能改变结果，进程将不再属于ssh的子进程</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1         ├─sshd(1472)─┬─sshd(20967)───bash(20971)───pstree(21685)</span><br><span class="line">2         │            └─sshd(21472)───bash(21476)</span><br><span class="line">3         ├─tail(21683)</span><br></pre></td></tr></table></figure>


<p>4、disown命令</p>
<p>我们已经知道，如果事先在命令前加上 nohup 或者 setsid 就可以避免 HUP 信号的影响。但是如果我们未加任何处理就已经提交了命令，该如何补救才能让它避免 HUP 信号的影响呢？</p>
<ul>
<li>用<code>disown -h *jobspec*</code>来使某个作业忽略HUP信号。</li>
<li>用<code>disown -ah </code>来使所有的作业都忽略HUP信号。</li>
<li>用<code>disown -rh </code>来使正在运行的作业忽略HUP信号。</li>
</ul>
<p>需要注意的是，当使用过 disown 之后，会将把目标作业从作业列表中移除，我们将不能再使用<code>jobs</code>来查看它，但是依然能够用<code>ps -ef</code>查找到它。</p>
<p>5、screen 命令</p>
<ul>
<li>用<code>screen -dmS *session name*</code>来建立一个处于断开模式下的会话（并指定其会话名）。</li>
<li>用<code>screen -list </code>来列出所有会话。</li>
<li>用<code>screen -r *session name*</code>来重新连接指定会话。</li>
<li>用快捷键<code>CTRL-a d </code>来暂时断开当前会话。</li>
</ul>
<p>6、PS命令</p>
<p>在ps命令中，“-T”选项可以开启线程查看。下面的命令列出了由进程号为<pid>的进程创建的所有线程。</p>
<p> ps -T -p <pid></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">1 [root@Searchsvc1 go-mysql-elasticsearch]# ps -T -p 21813</span><br><span class="line">2   PID  SPID TTY          TIME CMD</span><br></pre></td></tr></table></figure>


<p>“SID”栏表示线程ID，而“CMD”栏则显示了线程名称。</p>
<p>7、 Top命令</p>
<p>top命令可以实时显示各个线程情况。要在top输出中开启线程查看，请调用top命令的“-H”选项，该选项会列出所有Linux线程。在top运行时，你也可以通过按“H”键将线程查看模式切换为开或关。</p>
<p>1、 top -H</p>
<p>2、要让top输出某个特定进程<pid>并检查该进程内运行的线程状况：top -H -p <pid>。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/08/16/sql%E4%BC%98%E5%8C%96/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2021/08/16/sql%E4%BC%98%E5%8C%96/" class="post-title-link" itemprop="url">SQL 优化</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-08-16 16:58:33" itemprop="dateCreated datePublished" datetime="2021-08-16T16:58:33+08:00">2021-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-10-19 10:00:46" itemprop="dateModified" datetime="2021-10-19T10:00:46+08:00">2021-10-19</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br></pre></td><td class="code"><pre><span class="line">1、对查询进行优化，应尽量避免全表扫描，首先应考虑在 where 及 order by 涉及的列上建立索引。</span><br><span class="line"></span><br><span class="line">2、应尽量避免在 where 子句中使用!&#x3D;或&lt;&gt;操作符，否则将引擎放弃使用索引而进行全表扫描。</span><br><span class="line"></span><br><span class="line">3、应尽量避免在 where 子句中对字段进行 null 值判断，否则将导致引擎放弃使用索引而进行全表扫描，如：</span><br><span class="line">select id from t where num is null</span><br><span class="line">可以在num上设置默认值0，确保表中num列没有null值，然后这样查询：</span><br><span class="line">select id from t where num&#x3D;0</span><br><span class="line"></span><br><span class="line">4、应尽量避免在 where 子句中使用 or 来连接条件，否则将导致引擎放弃使用索引而进行全表扫描，如：</span><br><span class="line">select id from t where num&#x3D;10 or num&#x3D;20</span><br><span class="line">可以这样查询：</span><br><span class="line">select id from t where num&#x3D;10</span><br><span class="line">union all</span><br><span class="line">select id from t where num&#x3D;20</span><br><span class="line"></span><br><span class="line">5、下面的查询也将导致全表扫描：</span><br><span class="line">select id from t where name like ‘%abc%’</span><br><span class="line">若要提高效率，可以考虑全文检索。</span><br><span class="line"></span><br><span class="line">6、in 和 not in 也要慎用，否则会导致全表扫描，如：</span><br><span class="line">select id from t where num in(1,2,3)</span><br><span class="line">对于连续的数值，能用 between 就不要用 in 了：</span><br><span class="line">select id from t where num between 1 and 3</span><br><span class="line"></span><br><span class="line">7、如果在 where 子句中使用参数，也会导致全表扫描。因为SQL只有在运行时才会解析局部变量，但优化程序不能将访问计划的选择推迟到运行时；它必须在编译时进行选择。然而，如果在编译时建立访问计划，变量的值还是未知的，因而无法作为索引选择的输入项。如下面语句将进行全表扫描：</span><br><span class="line">select id from t where num&#x3D;@num</span><br><span class="line">可以改为强制查询使用索引：</span><br><span class="line">select id from t with(index(索引名)) where num&#x3D;@num</span><br><span class="line"></span><br><span class="line">8、应尽量避免在 where 子句中对字段进行表达式操作，这将导致引擎放弃使用索引而进行全表扫描。如：</span><br><span class="line">select id from t where num&#x2F;2&#x3D;100</span><br><span class="line">应改为:</span><br><span class="line">select id from t where num&#x3D;100*2</span><br><span class="line"></span><br><span class="line">9、应尽量避免在where子句中对字段进行函数操作，这将导致引擎放弃使用索引而进行全表扫描。如：</span><br><span class="line">select id from t where substring(name,1,3)&#x3D;’abc’–name以abc开头的id</span><br><span class="line">select id from t where datediff(day,createdate,’2005-11-30′)&#x3D;0–‘2005-11-30’生成的id</span><br><span class="line">应改为:</span><br><span class="line">select id from t where name like ‘abc%’</span><br><span class="line">select id from t where createdate&gt;&#x3D;’2005-11-30′ and createdate&lt;‘2005-12-1’</span><br><span class="line"></span><br><span class="line">10、不要在 where 子句中的“&#x3D;”左边进行函数、算术运算或其他表达式运算，否则系统将可能无法正确使用索引。</span><br><span class="line"></span><br><span class="line">11、在使用索引字段作为条件时，如果该索引是复合索引，那么必须使用到该索引中的第一个字段作为条件时才能保证系统使用该索引，否则该索引将不会被使用，并且应尽可能的让字段顺序与索引顺序相一致。</span><br><span class="line"></span><br><span class="line">12、不要写一些没有意义的查询，如需要生成一个空表结构：</span><br><span class="line">select col1,col2 into #t from t where 1&#x3D;0</span><br><span class="line">这类代码不会返回任何结果集，但是会消耗系统资源的，应改成这样：</span><br><span class="line">create table #t(…)</span><br><span class="line"></span><br><span class="line">13、很多时候用 exists 代替 in 是一个好的选择：</span><br><span class="line">select num from a where num in(select num from b)</span><br><span class="line">用下面的语句替换：</span><br><span class="line">select num from a where exists(select 1 from b where num&#x3D;a.num)</span><br><span class="line"></span><br><span class="line">14、并不是所有索引对查询都有效，SQL是根据表中数据来进行查询优化的，当索引列有大量数据重复时，SQL查询可能不会去利用索引，如一表中有字段sex，male、female几乎各一半，那么即使在sex上建了索引也对查询效率起不了作用。</span><br><span class="line"></span><br><span class="line">15、索引并不是越多越好，索引固然可以提高相应的 select 的效率，但同时也降低了 insert 及 update 的效率，因为 insert 或 update 时有可能会重建索引，所以怎样建索引需要慎重考虑，视具体情况而定。一个表的索引数最好不要超过6个，若太多则应考虑一些不常使用到的列上建的索引是否有必要。</span><br><span class="line"></span><br><span class="line">16、应尽可能的避免更新 clustered 索引数据列，因为 clustered 索引数据列的顺序就是表记录的物理存储顺序，一旦该列值改变将导致整个表记录的顺序的调整，会耗费相当大的资源。若应用系统需要频繁更新 clustered 索引数据列，那么需要考虑是否应将该索引建为 clustered 索引。</span><br><span class="line"></span><br><span class="line">17、尽量使用数字型字段，若只含数值信息的字段尽量不要设计为字符型，这会降低查询和连接的性能，并会增加存储开销。这是因为引擎在处理查询和连接时会逐个比较字符串中每一个字符，而对于数字型而言只需要比较一次就够了。</span><br><span class="line"></span><br><span class="line">18、尽可能的使用char&#x2F;nchar 代替 varchar&#x2F;nvarchar ，因为首先变长字段存储空间小，可以节省存储空间，其次对于查询来说，在一个相对较小的字段内搜索效率显然要高些。</span><br><span class="line"></span><br><span class="line">19、任何地方都不要使用 select * from t ，用具体的字段列表代替“*”，不要返回用不到的任何字段。</span><br><span class="line"></span><br><span class="line">20、尽量使用表变量来代替临时表。如果表变量包含大量数据，请注意索引非常有限（只有主键索引）。</span><br><span class="line"></span><br><span class="line">21、避免频繁创建和删除临时表，以减少系统表资源的消耗。</span><br><span class="line"></span><br><span class="line">22、临时表并不是不可使用，适当地使用它们可以使某些例程更有效，例如，当需要重复引用大型表或常用表中的某个数据集时。但是，对于一次性事件，最好使用导出表。</span><br><span class="line"></span><br><span class="line">23、在新建临时表时，如果一次性插入数据量很大，那么可以使用 select into 代替 create table，避免造成大量 log ，以提高速度；如果数据量不大，为了缓和系统表的资源，应先create table，然后insert。</span><br><span class="line"></span><br><span class="line">24、如果使用到了临时表，在存储过程的最后务必将所有的临时表显式删除，先 truncate table ，然后 drop table ，这样可以避免系统表的较长时间锁定。</span><br><span class="line"></span><br><span class="line">25、尽量避免使用游标，因为游标的效率较差，如果游标操作的数据超过1万行，那么就应该考虑改写。</span><br><span class="line"></span><br><span class="line">26、使用基于游标的方法或临时表方法之前，应先寻找基于集的解决方案来解决问题，基于集的方法通常更有效。</span><br><span class="line"></span><br><span class="line">27、与临时表一样，游标并不是不可使用。对小型数据集使用 FAST_FORWARD 游标通常要优于其他逐行处理方法，尤其是在必须引用几个表才能获得所需的数据时。在结果集中包括“合计”的例程通常要比使用游标执行的速度快。如果开发时间允许，基于游标的方法和基于集的方法都可以尝试一下，看哪一种方法的效果更好。</span><br><span class="line"></span><br><span class="line">28、在所有的存储过程和触发器的开始处设置 SET NOCOUNT ON ，在结束时设置 SET NOCOUNT OFF 。无需在执行存储过程和触发器的每个语句后向客户端发送 DONE_IN_PROC 消息。</span><br><span class="line"></span><br><span class="line">29、尽量避免向客户端返回大数据量，若数据量过大，应该考虑相应需求是否合理。</span><br><span class="line"></span><br><span class="line">30、尽量避免大事务操作，提高系统并发能力。</span><br><span class="line"></span><br></pre></td></tr></table></figure>



      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/06/09/maven%20%E6%8C%87%E5%AE%9Aurl/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2021/06/09/maven%20%E6%8C%87%E5%AE%9Aurl/" class="post-title-link" itemprop="url">maven 指定单个JAR 的 url</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-09 00:00:00" itemprop="dateCreated datePublished" datetime="2021-06-09T00:00:00+08:00">2021-06-09</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-06-10 17:28:34" itemprop="dateModified" datetime="2021-06-10T17:28:34+08:00">2021-06-10</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p> 在不影响原来的配置的情况下，可以通过修改pom.xml文件，添加如下节点来修改URL</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">repositories</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">repository</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">id</span>&gt;</span>repository.hibernate<span class="tag">&lt;/<span class="name">id</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">name</span>&gt;</span>Hibernate jar<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">url</span>&gt;</span>http://mirrors.ibiblio.org/maven2<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">repository</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">repositories</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p> 这样就可以更换URL 了</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/04/28/wsl2%E5%B1%80%E5%9F%9F%E7%BD%91%E8%BF%9E%E6%8E%A5/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2021/04/28/wsl2%E5%B1%80%E5%9F%9F%E7%BD%91%E8%BF%9E%E6%8E%A5/" class="post-title-link" itemprop="url">wsl2局域网连接</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-04-28 00:00:00" itemprop="dateCreated datePublished" datetime="2021-04-28T00:00:00+08:00">2021-04-28</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-10-19 09:57:18" itemprop="dateModified" datetime="2021-10-19T09:57:18+08:00">2021-10-19</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="wsl2局域网连接"><a href="#wsl2局域网连接" class="headerlink" title="wsl2局域网连接"></a>wsl2局域网连接</h1><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 添加转发端口  powershell 管理员</span></span><br><span class="line">netsh interface portproxy add v4tov4 listenport=port connectaddress=127.0.0.1 listenaddress=* protocol=tcp</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 查看已转发的端口</span></span><br><span class="line">netsh interface portproxy show all</span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 删除转发端口</span></span><br><span class="line">netsh interface portproxy delete v4tov4 listenport=80 listenaddress=0.0.0.0 </span><br><span class="line"><span class="meta">#</span><span class="bash"> 注意 写的是0.0.0.0删的时候也需要是0.0.0.0进行对应，不然会提示找不到文件</span></span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/03/29/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E7%99%BB%E5%BD%95%E9%80%BB%E8%BE%91/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2021/03/29/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E7%99%BB%E5%BD%95%E9%80%BB%E8%BE%91/" class="post-title-link" itemprop="url">微信小程序登录逻辑</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-03-29 14:43:09" itemprop="dateCreated datePublished" datetime="2021-03-29T14:43:09+08:00">2021-03-29</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-10-19 10:00:36" itemprop="dateModified" datetime="2021-10-19T10:00:36+08:00">2021-10-19</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <ol>
<li>小程序发起请求获取当前用户的 code (<code>通过 wx.login 接口获得临时登录凭证 code</code> ) </li>
<li>将 <code>code</code> 发送到后台服务进行登录逻辑。</li>
<li> 后台接受到请求后判断用户是否登录，若已登录，则直接返回<code>token</code></li>
<li>未登录则用<code>code</code> 取 <code>openid</code> ( <a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html">auth.code2Session</a> ), 用获取的<code>openid</code>在系统中查询是否存在用户</li>
<li>存在则用该用户登录，不存在则创建新用户并登录，然后返回 <code>token</code></li>
<li>小程序收到登录 token视为登录成功，开始请求用户信息 ( <a target="_blank" rel="noopener" href="https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html">wx.getUserInfo(Object object)</a> ) </li>
<li>小程序将获取到的用户信息传输给后台，将后台用户信息进行同步</li>
<li>结束登录</li>
</ol>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/01/15/HTML%E7%94%BB%E5%9C%86%EF%BC%88%E5%A4%AA%E9%98%B3%E8%80%80%E5%85%89%E6%95%88%E6%9E%9C%EF%BC%89/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2021/01/15/HTML%E7%94%BB%E5%9C%86%EF%BC%88%E5%A4%AA%E9%98%B3%E8%80%80%E5%85%89%E6%95%88%E6%9E%9C%EF%BC%89/" class="post-title-link" itemprop="url">HTML画圆（太阳耀光效果）</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-15 00:00:00" itemprop="dateCreated datePublished" datetime="2021-01-15T00:00:00+08:00">2021-01-15</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-09-26 16:09:01" itemprop="dateModified" datetime="2021-09-26T16:09:01+08:00">2021-09-26</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <ul>
<li>效果  自己改下颜色</li>
</ul>
<p><img src="http://file.ingrun.cn/Snipaste_2021-01-15_09-03-17.png" alt="Snipaste_2021-01-15_09-03-17.png"></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">&quot;en&quot;</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">title</span>&gt;</span>TweetShirt<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;utf-8&quot;</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">style</span> <span class="attr">type</span>=<span class="string">&quot;text/css&quot;</span>&gt;</span></span><br><span class="line">    canvas &#123;</span><br><span class="line">      border: 1px solid black;</span><br><span class="line">    &#125;</span><br><span class="line">  <span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="javascript">    <span class="built_in">window</span>.onload = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span></span><br><span class="line"><span class="javascript">      <span class="keyword">var</span> button = <span class="built_in">document</span>.getElementById(<span class="string">&quot;previewButton&quot;</span>);</span></span><br><span class="line">      button.onclick = previewHandler;</span><br><span class="line"><span class="javascript">      <span class="function"><span class="keyword">function</span> <span class="title">previewHandler</span>(<span class="params"></span>) </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> canvas = <span class="built_in">document</span>.getElementById(<span class="string">&quot;tshirtCanvas&quot;</span>);</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> context = canvas.getContext(<span class="string">&quot;2d&quot;</span>);</span></span><br><span class="line">        fillBackgroundColor(canvas, context);</span><br><span class="line"></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> selectObj = <span class="built_in">document</span>.getElementById(<span class="string">&quot;shape&quot;</span>);</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> index = selectObj.selectedIndex;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> shape = selectObj[index].value;</span></span><br><span class="line"><span class="javascript">        <span class="comment">//判断是方形还是圆形</span></span></span><br><span class="line"><span class="javascript">        <span class="keyword">if</span> (shape == <span class="string">&quot;squares&quot;</span>) &#123;</span></span><br><span class="line"><span class="javascript">          <span class="keyword">for</span> (<span class="keyword">var</span> squares = <span class="number">10</span>; squares &lt; <span class="number">12</span>; squares++) &#123;</span></span><br><span class="line">            drawSquare(canvas, context);</span><br><span class="line">          &#125;</span><br><span class="line"><span class="javascript">        &#125; <span class="keyword">else</span> <span class="keyword">if</span> (shape == <span class="string">&quot;circles&quot;</span>) &#123;</span></span><br><span class="line"><span class="javascript">          <span class="keyword">for</span> (<span class="keyword">var</span> circles = <span class="number">0</span>; circles &lt; <span class="number">20</span>; circles++) &#123;</span></span><br><span class="line">            drawCircle(canvas, context);</span><br><span class="line">          &#125;</span><br><span class="line">        &#125;</span><br><span class="line">      &#125;</span><br><span class="line"></span><br><span class="line"><span class="javascript">      <span class="function"><span class="keyword">function</span> <span class="title">fillBackgroundColor</span>(<span class="params">canvas, context</span>) </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> selectObj = <span class="built_in">document</span>.getElementById(<span class="string">&quot;backgroundColor&quot;</span>);</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> index = selectObj.selectedIndex;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> bgColor = selectObj.options[index].value;</span></span><br><span class="line">        context.fillStyle = bgColor;</span><br><span class="line">        context.fillRect(0, 0, canvas.width, canvas.height);</span><br><span class="line">      &#125;</span><br><span class="line"></span><br><span class="line"><span class="javascript">      <span class="comment">//封装方形</span></span></span><br><span class="line"><span class="javascript">      <span class="function"><span class="keyword">function</span> <span class="title">drawSquare</span>(<span class="params">canvas, context</span>) </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> w = <span class="built_in">Math</span>.floor(<span class="built_in">Math</span>.random() * <span class="number">40</span>);</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> x = <span class="built_in">Math</span>.floor(<span class="built_in">Math</span>.random() * canvas.width);</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> y = <span class="built_in">Math</span>.floor(<span class="built_in">Math</span>.random() * canvas.height);</span></span><br><span class="line"></span><br><span class="line"><span class="javascript">        context.fillStyle = <span class="string">&quot;blue&quot;</span>;</span></span><br><span class="line">        context.fillRect(x, y, w, w);</span><br><span class="line">      &#125;</span><br><span class="line"></span><br><span class="line"><span class="javascript">      <span class="comment">//封装圆形</span></span></span><br><span class="line"><span class="javascript">      <span class="function"><span class="keyword">function</span> <span class="title">drawCircle</span>(<span class="params">canvas, context</span>) </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> radius = <span class="built_in">Math</span>.floor(<span class="built_in">Math</span>.random() * <span class="number">40</span>);</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> x = <span class="built_in">Math</span>.floor(<span class="built_in">Math</span>.random() * canvas.width);</span></span><br><span class="line"><span class="javascript">        <span class="keyword">var</span> y = <span class="built_in">Math</span>.floor(<span class="built_in">Math</span>.random() * canvas.height);</span></span><br><span class="line"></span><br><span class="line">        context.beginPath();</span><br><span class="line"><span class="javascript">        context.arc(x, y, radius, <span class="number">0</span>, degreesToRadians(<span class="number">360</span>), <span class="literal">true</span>);</span></span><br><span class="line"><span class="javascript">        context.fillStyle = <span class="string">&quot;rgba(0,0,0, 0.6)&quot;</span>;</span></span><br><span class="line">        context.fill();</span><br><span class="line">      &#125;</span><br><span class="line"></span><br><span class="line"><span class="javascript">      <span class="function"><span class="keyword">function</span> <span class="title">degreesToRadians</span>(<span class="params">degrees</span>) </span>&#123;</span></span><br><span class="line"><span class="javascript">        <span class="keyword">return</span> (degrees * <span class="built_in">Math</span>.PI) / <span class="number">180</span>;</span></span><br><span class="line">      &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">  <span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">canvas</span> <span class="attr">id</span>=<span class="string">&quot;tshirtCanvas&quot;</span> <span class="attr">width</span>=<span class="string">&quot;600&quot;</span> <span class="attr">height</span>=<span class="string">&quot;200&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">p</span>&gt;</span>Please update your brower to use TweetShirt<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">canvas</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">form</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">p</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">label</span> <span class="attr">for</span>=<span class="string">&quot;backgroundColor&quot;</span>&gt;</span>Select background color:<span class="tag">&lt;/<span class="name">label</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">select</span> <span class="attr">id</span>=<span class="string">&quot;backgroundColor&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;white&quot;</span> <span class="attr">selected</span>=<span class="string">&quot;selected&quot;</span>&gt;</span>White<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;black&quot;</span>&gt;</span>Black<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">select</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">p</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">label</span> <span class="attr">for</span>=<span class="string">&quot;shape&quot;</span>&gt;</span>Circles or squares?<span class="tag">&lt;/<span class="name">label</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">select</span> <span class="attr">id</span>=<span class="string">&quot;shape&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;none&quot;</span> <span class="attr">selected</span>=<span class="string">&quot;selected&quot;</span>&gt;</span>Neither<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;circles&quot;</span>&gt;</span>Circles<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;squares&quot;</span>&gt;</span>squares<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">select</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">p</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;button&quot;</span> <span class="attr">name</span>=<span class="string">&quot;previewButton&quot;</span> <span class="attr">id</span>=<span class="string">&quot;previewButton&quot;</span> <span class="attr">value</span>=<span class="string">&quot;Preview&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/01/14/SpringBoot%E6%95%B4%E5%90%88Swagger3%E7%94%9F%E6%88%90%E6%8E%A5%E5%8F%A3%E6%96%87%E6%A1%A3/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2021/01/14/SpringBoot%E6%95%B4%E5%90%88Swagger3%E7%94%9F%E6%88%90%E6%8E%A5%E5%8F%A3%E6%96%87%E6%A1%A3/" class="post-title-link" itemprop="url">SpringBoot整合Swagger3生成接口文档</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-01-14 00:00:00 / 修改时间：17:50:20" itemprop="dateCreated datePublished" datetime="2021-01-14T00:00:00+08:00">2021-01-14</time>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>前后端分离的项目，接口文档的存在十分重要。与手动编写接口文档不同，swagger是一个自动生成接口文档的工具，在需求不断变更的环境下，手动编写文档的效率实在太低。与swagger2相比新版的swagger3配置更少，使用更加方便。</p>
<h2 id="一、pom文件中引入Swagger3依赖"><a href="#一、pom文件中引入Swagger3依赖" class="headerlink" title="一、pom文件中引入Swagger3依赖"></a>一、pom文件中引入Swagger3依赖</h2><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">     <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>io.springfox<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>springfox-boot-starter<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.0.0<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>


<h2 id="二、Application上面加入-EnableOpenApi注解"><a href="#二、Application上面加入-EnableOpenApi注解" class="headerlink" title="二、Application上面加入@EnableOpenApi注解"></a>二、Application上面加入@EnableOpenApi注解</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@EnableOpenApi</span></span><br><span class="line"><span class="meta">@SpringBootApplication</span></span><br><span class="line"><span class="meta">@MapperScan(basePackages = &#123;&quot;cn.ruiyeclub.dao&quot;&#125;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Swagger3Application</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        SpringApplication.run(Swagger3Application.class, args);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;	</span><br></pre></td></tr></table></figure>


<h2 id="三、Swagger3Config的配置"><a href="#三、Swagger3Config的配置" class="headerlink" title="三、Swagger3Config的配置"></a>三、Swagger3Config的配置</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Configuration</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Swagger3Config</span> </span>&#123;</span><br><span class="line">    <span class="meta">@Bean</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Docket <span class="title">createRestApi</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> Docket(DocumentationType.OAS_30)</span><br><span class="line">                .apiInfo(apiInfo())</span><br><span class="line">                .select()</span><br><span class="line">                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))</span><br><span class="line">                .paths(PathSelectors.any())</span><br><span class="line">                .build();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> ApiInfo <span class="title">apiInfo</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> ApiInfoBuilder()</span><br><span class="line">                .title(<span class="string">&quot;Swagger3接口文档&quot;</span>)</span><br><span class="line">                .description(<span class="string">&quot;更多请咨询服务开发者&quot;</span>)</span><br><span class="line">                .version(<span class="string">&quot;1.0&quot;</span>)</span><br><span class="line">                .build();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<h2 id="四、Swagger注解的使用说明"><a href="#四、Swagger注解的使用说明" class="headerlink" title="四、Swagger注解的使用说明"></a>四、Swagger注解的使用说明</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Api</span>：用在请求的类上，表示对类的说明</span><br><span class="line">    tags=<span class="string">&quot;说明该类的作用，可以在UI界面上看到的注解&quot;</span></span><br><span class="line">    value=<span class="string">&quot;该参数没什么意义，在UI界面上也看到，所以不需要配置&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@ApiOperation</span>：用在请求的方法上，说明方法的用途、作用</span><br><span class="line">    value=<span class="string">&quot;说明方法的用途、作用&quot;</span></span><br><span class="line">    notes=<span class="string">&quot;方法的备注说明&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@ApiImplicitParams</span>：用在请求的方法上，表示一组参数说明</span><br><span class="line">    <span class="meta">@ApiImplicitParam</span>：用在<span class="meta">@ApiImplicitParams</span>注解中，指定一个请求参数的各个方面</span><br><span class="line">        name：参数名</span><br><span class="line">        value：参数的汉字说明、解释</span><br><span class="line">        required：参数是否必须传</span><br><span class="line">        paramType：参数放在哪个地方</span><br><span class="line">            · header --&gt; 请求参数的获取：<span class="meta">@RequestHeader</span></span><br><span class="line">            · query --&gt; 请求参数的获取：<span class="meta">@RequestParam</span></span><br><span class="line">            · path（用于restful接口）--&gt; 请求参数的获取：<span class="meta">@PathVariable</span></span><br><span class="line">            · div（不常用）</span><br><span class="line">            · form（不常用）    </span><br><span class="line">        dataType：参数类型，默认String，其它值dataType=<span class="string">&quot;Integer&quot;</span>       </span><br><span class="line">        defaultValue：参数的默认值</span><br><span class="line"></span><br><span class="line"><span class="meta">@ApiResponses</span>：用在请求的方法上，表示一组响应</span><br><span class="line">    <span class="meta">@ApiResponse</span>：用在<span class="meta">@ApiResponses</span>中，一般用于表达一个错误的响应信息</span><br><span class="line">        code：数字，例如<span class="number">400</span></span><br><span class="line">        message：信息，例如<span class="string">&quot;请求参数没填好&quot;</span></span><br><span class="line">        response：抛出异常的类</span><br><span class="line"></span><br><span class="line"><span class="meta">@ApiModel</span>：用于响应类上，表示一个返回响应数据的信息</span><br><span class="line">            （这种一般用在post创建的时候，使用<span class="meta">@RequestBody</span>这样的场景，</span><br><span class="line">            请求参数无法使用<span class="meta">@ApiImplicitParam</span>注解进行描述的时候）</span><br><span class="line">    <span class="meta">@ApiModelProperty</span>：用在属性上，描述响应类的属性</span><br></pre></td></tr></table></figure>


<p>Controller层的配置：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="meta">@Api( tags = &quot;活动管理&quot; )</span></span><br><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="meta">@RequestMapping(&quot;/activity&quot;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ActivityController</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Resource</span></span><br><span class="line">    <span class="keyword">private</span> ActivityService activityService;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@ApiOperation(&quot;获取活动信息&quot;)</span></span><br><span class="line">    <span class="meta">@GetMapping(&quot;/get/&#123;id&#125;&quot;)</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Object <span class="title">get</span><span class="params">(<span class="meta">@PathVariable</span> String id)</span></span>&#123;</span><br><span class="line">        <span class="keyword">return</span> ResponseUtils.success(activityService.get(id));</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@ApiOperation(&quot;删除活动信息&quot;)</span></span><br><span class="line">    <span class="meta">@PostMapping(&quot;/del/&#123;id&#125;&quot;)</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Object <span class="title">del</span><span class="params">(<span class="meta">@PathVariable</span> String id)</span></span>&#123;</span><br><span class="line">        <span class="keyword">return</span> ResponseUtils.success(activityService.del(id));</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@ApiOperation(&quot;添加活动信息&quot;)</span></span><br><span class="line">    <span class="meta">@PostMapping(&quot;/add&quot;)</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Object <span class="title">add</span><span class="params">(<span class="meta">@RequestBody</span> Activity activity)</span></span>&#123;</span><br><span class="line">        <span class="keyword">return</span> ResponseUtils.success(activityService.add(activity));</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@ApiOperation(&quot;修改活动信息&quot;)</span></span><br><span class="line">    <span class="meta">@PostMapping(&quot;/upd&quot;)</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Object <span class="title">upd</span><span class="params">(<span class="meta">@RequestBody</span> Activity activity)</span></span>&#123;</span><br><span class="line">        <span class="keyword">return</span> ResponseUtils.success(activityService.upd(activity));</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<h2 id="五、访问地址"><a href="#五、访问地址" class="headerlink" title="五、访问地址"></a>五、访问地址</h2><ul>
<li>Swagger的访问路径由port/swagger-ui.html 改成了 port/swagger-ui/ 或 <code>ip:port/swagger-ui/index.html</code></li>
</ul>
<p><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/161947638">https://zhuanlan.zhihu.com/p/161947638</a></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/01/04/mysql5.7/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="ingrun">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ingrun">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/blog/2021/01/04/mysql5.7/" class="post-title-link" itemprop="url">CentOS7 yum方式安装MySQL5.7</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-01-04 17:25:11" itemprop="dateCreated datePublished" datetime="2021-01-04T17:25:11+08:00">2021-01-04</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-01-05 11:15:15" itemprop="dateModified" datetime="2021-01-05T11:15:15+08:00">2021-01-05</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>转载至博客：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/bigbrotherer/p/7241845.html">https://www.cnblogs.com/bigbrotherer/p/7241845.html</a></p>
<p>在CentOS中默认安装有MariaDB，这个是MySQL的分支，但为了需要，还是要在系统中安装MySQL，而且安装完成之后可以直接覆盖掉MariaDB。</p>
<h3 id="1-下载并安装MySQL官方的-Yum-Repository"><a href="#1-下载并安装MySQL官方的-Yum-Repository" class="headerlink" title="1 下载并安装MySQL官方的 Yum Repository"></a>1 下载并安装MySQL官方的 Yum Repository</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost ~]<span class="comment"># wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm</span></span><br></pre></td></tr></table></figure>
<p> 使用上面的命令就直接下载了安装用的Yum Repository，大概25KB的样子，然后就可以直接yum安装了。</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/blog/2021/01/04/mysql5.7/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/blog/page/2/">2</a><a class="extend next" rel="next" href="/blog/page/2/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">ingrun</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/blog/archives/">
        
          <span class="site-state-item-count">16</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">ingrun</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/blog/lib/anime.min.js"></script>
  <script src="/blog/lib/velocity/velocity.min.js"></script>
  <script src="/blog/lib/velocity/velocity.ui.min.js"></script>

<script src="/blog/js/utils.js"></script>

<script src="/blog/js/motion.js"></script>


<script src="/blog/js/schemes/pisces.js"></script>


<script src="/blog/js/next-boot.js"></script>




  




  
<script src="/blog/js/local-search.js"></script>













  

  

</body>
</html>
